<?php
class Admin_Form_Search_Hotel extends Apps_Plugin_Grid_Search_Abstract {
    public function preInit() {
        $dMapper 			= new M_Tool_DataMapper();
        $hotelTypeList 		= $dMapper->mapKeyValue(new M_DbTable_HotelType(), 'id', 'title');

        $advancedCriteria = array(
            'title' => array(
                    'h.name',
                    self::$criteriaStringLike,
                    array(
                            'element'  => self::ELEMENT_TEXT,
                            'label'    => 'Tên khách sạn',
                    )
            ),
            'category' => array(
            		'h.hotel_type_id',
            		self::$criteriaSimple,
					array(
							'element'	   => self::ELEMENT_SELECT,
							'label'		   => 'Loại khách sạn',
							'multiOptions' => $hotelTypeList
					)
            ),
            'phone' => array(
                    'h.phone',
                    self::$criteriaStringLike,
                    array(
                            'element'  => self::ELEMENT_TEXT,
                            'label'    => 'Điện thoại',
                    )
            ),
            'email' => array(
                    'h.email',
                    self::$criteriaStringLike,
                    array(
                            'element'  => self::ELEMENT_TEXT,
                            'label'    => 'Email',
                    )
            ),
            'address' => array(
                    'h.address',
                    self::$criteriaStringLike,
                    array(
                            'element'  => self::ELEMENT_TEXT,
                            'label'    => 'Địa chỉ',
                    )
            )
//             'km' => array(
//             		'h.special_offer',
//             		self::$criteriaStringLike,
// 					array(
// 							'element'	   => self::ELEMENT_SELECT,
// 							'label'		   => 'Khuyến mãi',
// 							'multiOptions' => array(M_DbTable_Hotel::SPECIAL_OFFER_TRUE  => 'Có',
// 													M_DbTable_Hotel::SPECIAL_OFFER_FALSE => 'Không')
// 					)
//             ),
//             'bc' => array(
//             		'h.best_selling',
//             		self::$criteriaStringLike,
// 					array(
// 							'element'	   => self::ELEMENT_SELECT,
// 							'label'		   => 'Bán chạy',
// 							'multiOptions' => array(M_DbTable_Hotel::BEST_SELLING_TRUE 	=> 'Có',
// 													M_DbTable_Hotel::BEST_SELLING_FALSE => 'Không')
// 					)
//             )
        );

        $simpleCriteria = array(
        		array('h.id LIKE ?', '%%%s%%'),
        		array('h.name LIKE ?', '%%%s%%'),
        		array('h.phone LIKE ?', '%%%s%%'),
        		array('h.email LIKE ?', '%%%s%%'),
        		array('h.address LIKE ?', '%%%s%%'),
        		array('h_t.title LIKE ?', '%%%s%%')
        );

        $this->setAdvCriteria($advancedCriteria);
        $this->setSplCriteria($simpleCriteria);
    }
}